package B2;

import com.github.oxo42.stateless4j.delegates.FuncBoolean;

import java.util.Scanner;

public class GuardCondition {
    private int cnt=0; //当前已经输入的字符位数
    private int wa_cnt=0; //当前错误次数
    private boolean Pwd_is_correct; //当前密码是否正确
    private boolean IsLocked; //当前是否为锁定状态
    Scanner sc =new Scanner(System.in);
    FuncBoolean iscorrect(){
        return ()-> Pwd_is_correct;
    } //密码是否正确
    FuncBoolean isnotcorrect(){
        return ()-> !Pwd_is_correct;
    }
    FuncBoolean isLocking(){
        return ()-> IsLocked;
    } //当前是否是锁定状态
    FuncBoolean isnotLocking(){
        return ()-> !IsLocked;
    }
    FuncBoolean hasatry(){
        return () -> cnt==4;
    }
    FuncBoolean haschance(){
        return ()-> !IsLocked;
    }
    void add_a_wa_cnt() { //增加密码错误次数
        wa_cnt+=1;
        if(wa_cnt==3) {
            wa_cnt = 0;
            IsLocked = true;
        }
    }
    void add_a_character() { //多输入一个字符
        cnt+=1;
        if(cnt>=4)
            cnt=4;
    }
    int get_wa_cnt() {
        return wa_cnt;
    }
    void setPwd_is_correct(boolean pwd_is_correct) {
        Pwd_is_correct=pwd_is_correct;
    }
    void setIsLock(boolean isLock) {
        IsLocked=isLock;
    }
}


